package com.sfac.springBoot.modules.test.dao;

import com.sfac.springBoot.modules.test.entity.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description StudentDao
 * @Author HymanHu
 * @Date 2022/7/1 14:57
 */
@Repository
public interface StudentDao extends JpaRepository<Student, Integer> {

	List<Student> findByStudentName(String studentName);

	@Modifying
//	@Query(nativeQuery = true, value = "update test_student set student_name = :#{#student.studentName} " +
//			"where id = :#{#student.id}")
	@Query(value = "update Student set studentName = :#{#student.studentName} " +
			"where id = :#{#student.id}")
	void updateStudent(@Param("student") Student student);
}
